package com.societyGames.grid
{
import com.greensock.TweenNano;
import com.societyGames.action.Action;

public class GridMoveToAction extends Action
{
  private var _gridObject:GridObject;
  private var _endX:Number;
  private var _endY:Number;
  private var _duration:Number;
  private var _easeFunction:Function;

  public function GridMoveToAction(gridObject:GridObject, endX:Number, endY:Number, duration:Number, easeFunction:Function)
  {
    this._gridObject = gridObject;
    this._endX = endX;
    this._endY = endY;
    this._duration = duration;
    this._easeFunction = easeFunction;
  }

  public override function startAction():void
  {
    TweenNano.to(_gridObject, _duration, {gridX: _endX, gridY: _endY, onComplete: onComplete, ease: _easeFunction});
  }

  protected function onComplete():void
  {
    this._completeEventObject.dispatchEvent();
  }
}
}